package com.math3d;

/**
 * Created by JhonKkk on 2018/11/3.
 */

public class MoreMath {
    float InvSqrt(float x)
    {
        float xhalf = 0.5f * x;
        int i = (int)x;
        //i = 0x5f3759df - (i >> 1);      // 计算第一个近似根
        i = 0x5f375a86 - (i >> 1);
        x = (float)i;
        x = x * (1.5f - xhalf * x * x); // 牛顿迭代法
        return x;
    }
}
